Homework 04 - Simplex method

In python we can find a set of libraries which has been implemented for a wide community of developers, let's use one of these. Pymprog is one library which implements the simplex method.


In [9]:
from pymprog import *

Let's define our variables in a symbolic way.


In [11]:
x, y = var('x,y')

Now we are going to set our restrictions.


In [12]:
maximize(20*x+30*y, 'profit')
3*x + 6*y <= 150
x + 0.5*y <= 22
x + y <= 275
solve()

print 'pasteles tipo P = %g;' % x.primal
print 'pasteles tipo Q = %g;' % y.primal


pasteles tipo P = 12.6667;
pasteles tipo Q = 18.6667;

In [ ]: